home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / dsort.doc < prev    next >
Text File  |  1995-03-31  |  4KB  |  119 lines

  1. Author: Kevin Jessup                                          August 20, 1990 
  2.  
  3. The following three programs make up a very useful directory sorting utility. 
  4. Note that they are based on the infamous and painfully slow bubble sort 
  5. algorithm.  If you have a large directory, the programs may take a couple 
  6. of minutes to execute.  It still is a lot faster that sorting your directory 
  7. manually.  Hope you like them! 
  8.  
  9.                                                          Kevin Jessup 
  10.                                                          9118 N. 85th St. 
  11.                                                          Milwaukee, WI 53224 
  12.                                                          Office: (414) 362-2020 
  13.                                                          Home:   (414) 355-9752 
  14.  
  15. ******************************************************************************** 
  16. File name: VLPARSE 
  17. Bytes:     184 
  18. Ckecksum:  9754 (HEX) 
  19. Function:  VLPARSE will take a list of variables and either delete or save 
  20.            all variables of a given type from that list. 
  21.  
  22. Inputs:    Level three: LIST of variables 
  23.            Level two:   object type (see page 97 of manual) 
  24.            Level one:   0 (to save the variables) or 1 (to delete the variables) 
  25.  
  26. Outputs:   The parsed LIST. 
  27.  
  28. Example 1: 
  29.           1) From your top level directory, execute the VARS command. 
  30.           2) A list of variables should now be on the stack. 
  31.           3) Enter 15 on the stack (this specifies a directory object). 
  32.           4) Enter 0 on the stack (this tell VLPARSE to save all occurences 
  33.               of the object). 
  34.           5) Execute VLPARSE. 
  35.           6) A list of all directory objects remains on the stack. 
  36.          
  37. Example 2: 
  38.           Get a list of all variables in the current directory that do NOT 
  39.           contain PROGRAM objects. 
  40.           1) Execute the VARS command. 
  41.           2) Enter the real number 8 (specifies a program object). 
  42.           3) Enter the real number 1 (delete variables of specified type). 
  43.           4) Execute VLPARSE. 
  44.           5) A list of all variables in the current directory that are NOT 
  45.              program objects remains on the STACK.  If all objects in the 
  46.              current directory WERE program objects, the list is empty. 
  47.  
  48. Program Listing: 
  49.  
  50. %%HP: T(3)A(D)F(.); 
  51. \<< { } \-> l t d n 
  52.   \<< 
  53.     IF l SIZE DUP 
  54.     THEN 1 SWAP 
  55.       FOR i 'l' i GET 
  56.         IF VTYPE t == d XOR 
  57.         THEN n 'l' i GET 1 \->LIST + 'n' STO 
  58.         END 
  59.       NEXT 
  60.     ELSE DROP 
  61.     END n 
  62.   \>> 
  63. \>> 
  64.  
  65. ******************************************************************************** 
  66. File name: ALPHSORT 
  67. Bytes:     154 
  68. Checksum:  E915 (HEX) 
  69. Function:  Sort a list of variables alphabeticly. 
  70.            This is the same bubble sort function that is on page 561 of the 
  71.            manuals except that a string conversion is performed on the 
  72.            list objects before the comparison.  The bubble sort is probably 
  73.            the slowest of the numerous sorting routines available.  If 
  74.            anyone has seen an implementation of the shell sort or quick sort 
  75.            algorithms on an HP48SX, please let me know!  Right now I have 
  76.            neither the time nor the inclination to implement them. 
  77.  
  78. Inputs:    List of objects on level one. 
  79.  
  80. Outputs:   Alphabeticaly sorted list. 
  81.  
  82. Program listing: 
  83.  
  84. %%HP: T(3)A(D)F(.); 
  85. \<< DUP SIZE 1 - 1 
  86.   FOR j 1 j 
  87.     FOR k k GETI \-> n1 
  88.       \<< GETI \-> n2 
  89.         \<< DROP 
  90.           IF n1 \->STR n2 \->STR > 
  91.           THEN k n2 PUTI n1 PUT 
  92.           END 
  93.         \>> 
  94.       \>> 
  95.     NEXT -1 
  96.   STEP 
  97. \>> 
  98.  
  99. ******************************************************************************** 
  100. File name: DSORT (Directory SORT) 
  101. Bytes:     101.5 
  102. Ckecksum:  ED34 (HEX) 
  103. Function:  DSORT will sort a directory alphabeticly.  Sub-directores will 
  104.            be sorted first, followed by all other objects.  Note that 
  105.            DSORT calls the above two progams as subroutines. 
  106.  
  107. Inputs:    None 
  108.  
  109. Outputs:   The current directory is sorted.  The actual variables within the 
  110.            subdirectories are NOT sorted. 
  111.  
  112. Program listing: 
  113.  
  114. %%HP: T(3)A(D)F(.); 
  115. \<< VARS 15 0 VLPARSE ALPHSORT VARS 15 1 VLPARSE ALPHSORT + ORDER 
  116. \>> 
  117.  
  118. ***********************************[END]**************************************** 
  119.